# -*- coding:utf-8 -*-
import sys

reload(sys)
sys.setdefaultencoding("utf-8")


class HtmlOutputer(object):
    def collect_citydata(self, data):
        if data is None:
            return
            # set不支持index访问
            # 去重处理
        news_data = []
        for city in data:
            if city not in news_data:
                news_data.append(city)
        self.cities = news_data
        print "去重处理后,输出%d个" % len(self.cities)

    def output_cities(self):
        # 由于 self.cities  self.citiyUrls 长度是一致的
        fout = open('city.txt', 'w')
        for city in self.cities:
            fout.write(city['name'] + "," + city['url'] + "\n")
        print  "城市获取成功，输出在city.txt中"
